function currying<T>(exec:(...rest:Array<T>)=>any | T){
    const args:Array<T> = []
    return function curry(...rest:Array<T>){
        if(rest.length <= 0){
            return exec(...args)
        }else{
            args.push(...rest)
            return curry
        }
    }
}

// function _currying<T>(exec:(...rest:Array<T>)=>any | T){
//     const args:Array<T> = []
//     const curry = function(...rest:Array<T>){
//         args.push(...rest)
//         return curry
//     }
//     Function.prototype[Symbol.toPrimitive] = (hint:any)=>{
//         console.log(hint);
//         if(hint == "string"){
//             exec(...args)
//         }
//     }
//     return curry
// }

function demo(...rest:Array<number>){
    return rest.reduce((pre,cur)=>pre+cur,0)
}

console.log(currying<number>(demo)(1,2,3)(2,3,4)());

